Shared or common layout accross multiple pages

  • Usage

    1. Create common layout

    widgets/CommonLayout.dart

    
                import 'package:flutter/material.dart';
    
                  class CommonLayout extends StatelessWidget {
                    final Widget child;
    
                    CommonLayout({required this.child});
    
                    @override
                    Widget build(BuildContext context) {
                      return Scaffold(
                        appBar: AppBar(
                          title: Text('Common Title'), // You can customize this as needed
                        ),
                        body: Padding(
                          padding: EdgeInsets.all(16.0),
                          child: child,
                        ),
                      );
                    }
                  }
    
    
                  
    This CommonLayout widget has an AppBar and a body area where you can pass any child widget to be displayed.

    2. Pages

    
                import 'package:flutter/material.dart';
                import 'package:get/get.dart';
    
                class PageOne extends StatelessWidget {
                  @override
                  Widget build(BuildContext context) {
                    return CommonLayout(
                      child: Center(
                        child: Text('Page One Content'),
                      ),
                    );
                  }
                }
    
                class PageTwo extends StatelessWidget {
                  @override
                  Widget build(BuildContext context) {
                    return CommonLayout(
                      child: Center(
                        child: Text('Page Two Content'),
                      ),
                    );
                  }
                }